use std::fmt::{Display, Formatter};
use clap::Parser;

use super::check_input_file_path;


#[derive(Debug, Parser, Clone)]
pub struct TextSignOpts {
    #[arg(short, long, default_value = "-", value_parser = check_input_file_path)]
    pub input: String,

    #[arg(short, long,  value_parser = check_input_file_path)]
    pub key: String,

    #[arg(short, long, default_value = "blake3", value_parser = parse_format)]
    pub format: TextSignFormat,
}


#[derive(Debug, Parser, Clone)]
pub struct TextVerifyOpts {
    #[arg(short, long, default_value = "-", value_parser = check_input_file_path)]
    pub input: String,

    #[arg(short, long, default_value = "-", value_parser = check_input_file_path)]
    pub key: String,

    #[arg(short, long, default_value = "-", value_parser = check_input_file_path)]
    pub sign: String,

    #[arg(short, long, default_value = "blake3", value_parser = parse_format)]
    pub format: TextSignFormat,
}


#[derive(Debug, Parser, Copy, Clone)]
pub enum TextSignFormat {
    Blake3,
    // Ed22519,
}

fn parse_format(format: &str) -> anyhow::Result<TextSignFormat, String> {
    match format {
        "blake3" => Ok(TextSignFormat::Blake3),
        // "ed22519" => Ok(TextSignFormat::Ed22519),
        _ => Err("Invalid format".to_string()),
    }
}


#[derive(Debug, Clone,Parser)]
pub enum TextSubCommand {
    #[command(about = "Sign a message with private/share key")]
    Sign(TextSignOpts),
    #[command(about = "Verify a message")]
    Verify(TextVerifyOpts),

}
